var map = new AMap.Map("map", {
    center: [111.30,37.89],
    zoom: 11,
    pitch: 10,
    mapStyle: "amap://styles/darkblue",
    viewMode: "3D",
    features: ["bg", "road", "building", "point"],
});
var loca = new Loca.Container({
    map,
});
function addPolygon(data) {
    let polygon = new AMap.Polygon({
        path: data,
        fillColor: "#ccebc5",
        strokeOpacity: 1,
        fillOpacity: 0,
        strokeColor: "#5341fd",
        strokeWeight: 2,
        strokeStyle: "dashed",
        strokeDasharray: [5, 5],
    });
    map.add(polygon);
}
addPolygon(fangshan);
dateType=''
type='zw'
$(function(){
    // 终端坐标列表
    getTerminalList();
    // 终端运行情况
    getTerminalRunningData();
// 应用使用情况
    getUseData(dateType);
    // 各乡镇应用使用情况按钮组切换
    $(".use-tab-box>.use-tab-item").click(function () {
        $(this).parents(".use-tab-box").find(".use-tab-item").removeClass("use-tab-spec");
        $(this).addClass("use-tab-spec");
        dateType = $(this).attr("data-type");
        getUseData(dateType);
        getHotItemListData(type,dateType);
    });
    hotCaotainer = document.getElementById("perTownList");
    getHotItemListData(type);
    $(".town-tab>.town-tab-item").click(function () {
        $(this).parents(".town-tab").find(".town-tab-item").removeClass("town-tan-item-spec");
        $(this).addClass("town-tan-item-spec");
        type = $(this).attr("data-type");
        getHotItemListData(type,dateType);
    });
    // 政务类办件统计
    getHadGovernmentData();
    //证明类
    getHadProveData();
    // 查询类
    getHadQueryData();
    //   便民工具类
    getHadToolsData();
    // 各乡镇办件量统计
    getPerTownHelpData("");
    // 各乡镇办件量统计类型切换
    $(".per-count-tab-box>.per-count-tab-item").click(function () {
        $(this).parents(".per-count-tab-box").find(".per-count-tab-item").removeClass("per-spec-tab");
        $(this).addClass("per-spec-tab");
        var type = $(this).attr("data-type");
        getPerTownHelpData(type);
    });
})
// 终端运行情况
function getTerminalRunningData() {
    let onlineTerminal = document.getElementById("onlineTerminal"); //在线终端
    let malfunctionTerminal = document.getElementById("malfunctionTerminal"); //故障终端
    let offlineTerminal = document.getElementById("offlineTerminal"); //离线终端
    $.ajax({
        url: url + "/api/v1/terminal/terminalOperation",
        type: "get",
        headers: headers,
        success: function (data) {
            if (data.success) {
                $("#onlineTerminal").text(data.data.ZX);
                $("#malfunctionTerminal").text(data.data.GZ);
                $("#offlineTerminal").text(data.data.LX);
                const optionsData = [
                    {
                        name: "在线终端",
                        value: data.data.ZX,
                        itemStyle: {
                            //   opacity: 0.5,
                            color: "#1563FF",
                        },
                    },

                    {
                        name: "故障终端",
                        value: data.data.GZ,
                        itemStyle: {
                            //   opacity: 0.5,
                            color: "#E34D59",
                        },
                    },
                    {
                        name: "离线终端",
                        value: data.data.LX,
                        itemStyle: {
                            //   opacity: 0.5,
                            color: "#D0DEEE",
                        },
                    },
                ];
                setTerminalMap(optionsData);
            }
        },
    });
}
function setTerminalMap(data) {
    var terminalChart = echarts.init(document.getElementById("terminalMap"));
    const series = getPie3D(data, 0.8, 260, 28, 26, 0.5);
    option = {
        legend: {
            show: false,
            tooltip: {
                show: false,
            },
            icon: "circle",
            data: ["在线终端", "故障终端", "离线终端"],
            bottom: "5%",
            formatter: (name) => {
                if (data.length) {
                    const item = data.filter((item) => item.name === name)[0];
                    return `${name}\n{value|${item.value}}台`;
                }
            },
            textStyle: {
                color: "#fff",
                rich: {
                    value: {
                        fontSize: 20,
                        fontFamily: "TeX Gyre Adventor",
                        fontWeight: "bold",
                    },
                },
            },
        },
        animation: true,
        tooltip: {
            formatter: (params) => {
                if (
                    params.seriesName !== "mouseoutSeries" &&
                    params.seriesName !== "pie2d"
                ) {
                    return `${
                        params.seriesName
                    }<br/><span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${
                        params.color
                    };"></span>${option.series[params.seriesIndex].pieData.value + "台"}`;
                }
            },
            textStyle: {},
        },
        title: {
            x: "center",
            top: "0",
            textStyle: {
                color: "#fff",
                fontSize: 22,
            },
        },
        xAxis3D: {
            min: -1,
            max: 1,
        },
        yAxis3D: {
            min: -1,
            max: 1,
        },
        zAxis3D: {
            min: -1,
            max: 1,
        },
        grid3D: {
            show: false,
            boxHeight: 0.5,
            top: "-20%",
            // bottom: '50%',

            viewControl: {
                distance: 180,
                alpha: 25,
                beta: 60,
                zoomSensitivity: 0,
                autoRotate: false, // 自动旋转
            },
        },

        series: series,
    };

    terminalChart.setOption(option);
}
// 生成模拟 3D 饼图的配置项
function getPie3D(pieData, internalDiameterRatio) {
    let series = [];
    let sumValue = 0;
    let startValue = 0;
    let endValue = 0;
    let legendData = [];
    let k =
        typeof internalDiameterRatio !== "undefined"
            ? (1 - internalDiameterRatio) / (1 + internalDiameterRatio)
            : 1 / 3;

    // 为每一个饼图数据，生成一个 series-surface 配置
    for (let i = 0; i < pieData.length; i++) {
        sumValue += pieData[i].value;

        let seriesItem = {
            name:
                typeof pieData[i].name === "undefined" ? `series${i}` : pieData[i].name,
            type: "surface",
            parametric: true,
            wireframe: {
                show: false,
            },
            pieData: pieData[i],
            pieStatus: {
                selected: false,
                hovered: false,
                k: k,
            },
        };

        if (typeof pieData[i].itemStyle != "undefined") {
            let itemStyle = {};

            typeof pieData[i].itemStyle.color != "undefined"
                ? (itemStyle.color = pieData[i].itemStyle.color)
                : null;
            typeof pieData[i].itemStyle.opacity != "undefined"
                ? (itemStyle.opacity = pieData[i].itemStyle.opacity)
                : null;

            seriesItem.itemStyle = itemStyle;
        }
        series.push(seriesItem);
    }

    // 使用上一次遍历时，计算出的数据和 sumValue，调用 getParametricEquation 函数，
    // 向每个 series-surface 传入不同的参数方程 series-surface.parametricEquation，也就是实现每一个扇形。
    for (let i = 0; i < series.length; i++) {
        endValue = startValue + series[i].pieData.value;
        series[i].pieData.startRatio = startValue / sumValue;
        series[i].pieData.endRatio = endValue / sumValue;
        series[i].parametricEquation = getParametricEquation(
            series[i].pieData.startRatio,
            series[i].pieData.endRatio,
            false,
            false,
            k,
            series[i].pieData.value
        );

        startValue = endValue;

        legendData.push(series[i].name);
    }

    // // 补充一个透明的圆环，用于支撑高亮功能的近似实现。
    series.push({
        name: "mouseoutSeries",
        type: "surface",
        parametric: true,
        wireframe: {
            show: false,
        },
        itemStyle: {
            opacity: 0.1,
            color: "#E1E8EC",
        },
        parametricEquation: {
            u: {
                min: 0,
                max: Math.PI * 2,
                step: Math.PI / 20,
            },
            v: {
                min: 0,
                max: Math.PI,
                step: Math.PI / 20,
            },
            x: function (u, v) {
                return ((Math.sin(v) * Math.sin(u) + Math.sin(u)) / Math.PI) * 2;
            },
            y: function (u, v) {
                return ((Math.sin(v) * Math.cos(u) + Math.cos(u)) / Math.PI) * 2;
            },
            z: function (u, v) {
                return Math.cos(v) > 0 ? -0.5 : -5;
            },
        },
    });

    // // 补充一个透明的圆环，用于支撑高亮功能的近似实现。
    series.push({
        name: "mouseoutSeries",
        type: "surface",
        parametric: true,
        wireframe: {
            show: false,
        },
        itemStyle: {
            opacity: 0.1,
            color: "#E1E8EC",
        },
        parametricEquation: {
            u: {
                min: 0,
                max: Math.PI * 2,
                step: Math.PI / 20,
            },
            v: {
                min: 0,
                max: Math.PI,
                step: Math.PI / 20,
            },
            x: function (u, v) {
                return ((Math.sin(v) * Math.sin(u) + Math.sin(u)) / Math.PI) * 2;
            },
            y: function (u, v) {
                return ((Math.sin(v) * Math.cos(u) + Math.cos(u)) / Math.PI) * 2;
            },
            z: function (u, v) {
                return Math.cos(v) > 0 ? -5 : -7;
            },
        },
    });
    series.push({
        name: "mouseoutSeries",
        type: "surface",
        parametric: true,
        wireframe: {
            show: false,
        },
        itemStyle: {
            opacity: 0.1,
            color: "#E1E8EC",
        },

        parametricEquation: {
            u: {
                min: 0,
                max: Math.PI * 2,
                step: Math.PI / 20,
            },
            v: {
                min: 0,
                max: Math.PI,
                step: Math.PI / 20,
            },
            x: function (u, v) {
                return ((Math.sin(v) * Math.sin(u) + Math.sin(u)) / Math.PI) * 2.2;
            },
            y: function (u, v) {
                return ((Math.sin(v) * Math.cos(u) + Math.cos(u)) / Math.PI) * 2.2;
            },
            z: function (u, v) {
                return Math.cos(v) > 0 ? -7 : -7;
            },
        },
    });
    return series;
}
// 生成扇形的曲面参数方程，用于 series-surface.parametricEquation
function getParametricEquation(startRatio, endRatio, isSelected, isHovered, k, height) {
    // 计算
    let midRatio = (startRatio + endRatio) / 2;

    let startRadian = startRatio * Math.PI * 2;
    let endRadian = endRatio * Math.PI * 2;
    let midRadian = midRatio * Math.PI * 2;

    // 如果只有一个扇形，则不实现选中效果。
    if (startRatio === 0 && endRatio === 1) {
        isSelected = false;
    }

    // 通过扇形内径/外径的值，换算出辅助参数 k（默认值 1/3）
    k = typeof k !== "undefined" ? k : 1 / 3;

    // 计算选中效果分别在 x 轴、y 轴方向上的位移（未选中，则位移均为 0）
    let offsetX = isSelected ? Math.cos(midRadian) * 0.1 : 0;
    let offsetY = isSelected ? Math.sin(midRadian) * 0.1 : 0;

    // 计算高亮效果的放大比例（未高亮，则比例为 1）
    let hoverRate = isHovered ? 1.05 : 1;

    // 返回曲面参数方程
    return {
        u: {
            min: -Math.PI,
            max: Math.PI * 3,
            step: Math.PI / 32,
        },

        v: {
            min: 0,
            max: Math.PI * 2,
            step: Math.PI / 20,
        },

        x: function (u, v) {
            if (u < startRadian) {
                return (
                    offsetX + Math.cos(startRadian) * (1 + Math.cos(v) * k) * hoverRate
                );
            }
            if (u > endRadian) {
                return (
                    offsetX + Math.cos(endRadian) * (1 + Math.cos(v) * k) * hoverRate
                );
            }
            return offsetX + Math.cos(u) * (1 + Math.cos(v) * k) * hoverRate;
        },

        y: function (u, v) {
            if (u < startRadian) {
                return (
                    offsetY + Math.sin(startRadian) * (1 + Math.cos(v) * k) * hoverRate
                );
            }
            if (u > endRadian) {
                return (
                    offsetY + Math.sin(endRadian) * (1 + Math.cos(v) * k) * hoverRate
                );
            }
            return offsetY + Math.sin(u) * (1 + Math.cos(v) * k) * hoverRate;
        },

        z: function (u, v) {
            if (u < -Math.PI * 0.5) {
                return Math.sin(u);
            }
            if (u > Math.PI * 2.5) {
                return Math.sin(u);
            }
            return Math.sin(v) > 0 ? 1 * height : -1;
        },
    };
}
// 应用使用情况 queryType
function getUseData(type,dateType) {
    $.ajax({
        url: url + "/api/v1/terminal/terminalModuleUsage",
        type: "get",
        headers: headers,
        data: {queryType: type},
        success: function (data) {
            if (data.success) {
                var list = [];
                list.push({
                    name: "证明服务",
                    value: data.data.ZMFW,
                });
                list.push({
                    name: "便民服务",
                    value: data.data.BMFW,
                });
                list.push({
                    name: "公共服务",
                    value: data.data.GGFW,
                });
                list.push({
                    name: "政务服务",
                    value: data.data.ZWFW,
                });


                setUseChart(list);
                $("#use-zmfu").text(data.data.ZMFW);
                $("#use-bmsf").text(data.data.BMFW);
                $("#use-ggsf").text(data.data.GGFW);
                $("#use-zwsf").text(data.data.ZWFW);
            }
        },
    });
}
function setUseChart(data) {
    var useMapChart = echarts.init(document.getElementById("useMapChart"));
    var option = {
        tooltip: {
            trigger: "item",
        },
        legend: {
            show: false,
        },
        color: ["#d0deee", "#1563FF", "#34FFBF", "#0092FF"],
        series: [
            {
                name: "使用情况",
                type: "pie",
                radius: ["90%", "75%"],
                avoidLabelOverlap: false,
                itemStyle: {
                    borderRadius: 0,
                    borderColor: "#1a202a",
                    borderWidth: 5,
                },
                label: {
                    show: false,
                    position: "center",
                },
                emphasis: {
                    label: {
                        show: true,
                        fontSize: 14,
                        fontWeight: "bold",
                    },
                },
                labelLine: {
                    show: false,
                },
                data: data,
            },
        ],
    };
    useMapChart.setOption(option);
}
// 各乡镇终端使用情况
function getHotItemListData(type,dateType) {
    $.ajax({
        url: url + "/api/v1/terminal/terminalUsageByRegion",
        type: "get",
        data: { queryType: type,dateType:dateType },
        headers: headers,
        success: function (data) {
            if (data.success) {
                var str = "";
                hotCaotainer.innerHTML=''
                str+=' <li>' +
                    '<div class="list-index">序号</div>' +
                    '<div class="list-name">区划名称</div>' +
                    '<div class="list-num">使用量</div>' +
                    '</li>'
                data.data.forEach(function (item, index) {
                    str += "<li>";
                    if (index < 9) {
                        str +=
                            '<div class="item-index">0' +
                            (index + 1) +
                            "</div>";
                    } else {
                        str +=
                            '<div class="item-index">' +
                            (index + 1) +
                            "</div>";
                    }
                    str +=
                        '<div class="item-name">' +
                        item.QHMC +
                        "</div>" +
                        '<div class="item-num">' +
                        item.SYSL +
                        "</div>" +
                        "</li>";
                });
                hotCaotainer.innerHTML = str;
            }
        },
    });
}
// 政务类办件统计
function getHadGovernmentData() {
    let goverYear = document.getElementById("goverYear"); //政务服务类本年办件
    let goverMonth = document.getElementById("goverMonth"); //政务服务类本月办件
    let goverWeek = document.getElementById("goverWeek"); //政务服务类本周办件
    $.ajax({
        url: url + "/api/v1/business/govBusinessNum",
        type: "get",
        headers: headers,
        success: function (data) {
            if (data.success) {
                valueFlash(goverYear, data.data.BN, 1);
                valueFlash(goverMonth, data.data.BYY, 1);
                valueFlash(goverWeek, data.data.BZ, 1);
            }
        },
    });
}
//证明类统计
function getHadProveData() {
    let proveYear = document.getElementById("proveYear"); //证明类本年办件
    let proveMonth = document.getElementById("proveMonth"); //证明类本月办件
    let proveWeek = document.getElementById("proveWeek"); //证明类本周办件
    $.ajax({
        url: url + "/api/v1/business/provitionBusinessNum",
        type: "get",
        headers: headers,
        success: function (data) {
            if (data.success) {
                valueFlash(proveYear, data.data.BN, 1);
                valueFlash(proveMonth, data.data.BYY, 1);
                valueFlash(proveWeek, data.data.BZ, 1);
            }
        },
    });
}
// 查询类
function getHadQueryData() {
    let queryYear = document.getElementById("queryYear"); //查询类本年办件
    let queryMonth = document.getElementById("queryMonth"); //查询类本月办件
    let toolsWeek = document.getElementById("queryWeek"); //查询类本周办件
    $.ajax({
        url: url + "/api/v1/business/covBusinessNum",
        type: "get",
        headers: headers,
        data: {
            queryType: "cx",
        },
        success: function (data) {
            if (data.success) {
                valueFlash(queryYear, data.data.BN, 1);
                valueFlash(queryMonth, data.data.BYY, 1);
                valueFlash(queryWeek, data.data.BZ, 1);
            }
        },
    });
}
//   便民工具类
function getHadToolsData() {
    let toolsYear = document.getElementById("toolsYear"); //便民工具类本年办件
    let toolsMonth = document.getElementById("toolsMonth"); //便民工具类本月办件
    let toolsWeek = document.getElementById("toolsWeek"); //便民工具类本周办件
    $.ajax({
        url: url + "/api/v1/business/covBusinessNum",
        type: "get",
        headers: headers,
        data: {
            queryType: "bmgj",
        },
        success: function (data) {
            if (data.success) {
                valueFlash(toolsYear, data.data.BN, 1);
                valueFlash(toolsMonth, data.data.BYY, 1);
                valueFlash(toolsWeek, data.data.BZ, 1);
            }
        },
    });
}
// 各乡镇办件量统计
function getPerTownHelpData(type) {
    $.ajax({
        url: url + "/api/v1/business/businessNumByRegion",
        type: "get",
        headers: headers,
        data: { queryType: type },
        success: function (data) {
            if (data.success) {
                setPerTownCountMap(data.data);
            }
        },
    });
}
const chartIconList = [
    "./images/index/paiming_1.png",
    "./images/index/paiming_2.png",
    "./images/index/paiming_3.png",
    "./images/index/paiming_4.png",
    "./images/index/paiming_5.png",
    "./images/index/paiming_6.png",
    "./images/index/paiming_7.png",
    "./images/index/paiming_8.png",
    "./images/index/paiming_9.png",
    "./images/index/paiming_10.png",
    "./images/index/paiming_11.png",
    "./images/index/paiming_12.png",
];
function setPerTownCountMap(data) {
    var townCountChart = echarts.init(document.getElementById("perTownCount"));
    var option = {
        tooltip: {
            show: true,
            trigger: "item",
            padding: [8, 15],
            backgroundColor: "rgba(12, 51, 115,0.8)",
            borderColor: "rgba(3, 11, 44, 0.5)",
            textStyle: {
                color: "rgba(255, 255, 255, 1)",
            },
        },
        legend: {
            show: false,
        },
        grid: {
            left: "90",
            right: "16%",
            top: "0%",
            bottom: "0%",
        },
        xAxis: [
            {
                splitLine: {
                    show: false,
                },
                type: "value",
                show: false,
            },
        ],
        yAxis: [
            {
                splitLine: {
                    show: false,
                },
                axisLine: {
                    show: false,
                },
                type: "category",
                axisTick: {
                    show: false,
                },
                inverse: true,
                data: data.map((item) => item.QHMC),
                axisLabel: {
                    color: "#fff",
                    fontSize: 12,
                    margin: 10,
                    formatter: function (value, index) {
                        return `{img${index}|}{value|${value}}`;
                    },
                    rich: {
                        value: {
                            width: 55,
                        },
                        img0: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[0],
                            },
                        },
                        img1: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[1],
                            },
                        },
                        img2: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[2],
                            },
                        },
                        img3: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[3],
                            },
                        },
                        img4: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[4],
                            },
                        },
                        img5: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[5],
                            },
                        },
                        img6: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[6],
                            },
                        },
                        img7: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[7],
                            },
                        },
                        img8: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[8],
                            },
                        },
                        img9: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[9],
                            },
                        },
                        img10: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[10],
                            },
                        },
                        img11: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[11],
                            },
                        },
                        img12: {
                            width: 24,
                            height: 16,
                            backgroundColor: {
                                image: chartIconList[12],
                            },
                        },
                    },
                },
            },
            {
                type: "category",
                inverse: true,
                axisTick: "none",
                axisLine: "none",
                show: true,
                axisLabel: {
                    textStyle: {
                        color: "#fff",
                        fontWeight: 700,
                        fontSize:14
                    },
                    formatter: function (value) {
                        return value;
                    },
                },
                data: data.map((item) => item.BJSL),
            },
        ],
        series: [
            {
                name: "办件量",
                type: "bar",
                barWidth: 3, // 柱子宽度
                MaxSize: 0,
                showBackground: true,
                backgroundStyle: {
                    color: "rgba(255, 255, 255, 0.1)",
                },
                label: {
                    show: false,
                },
                data: data.map((item, index) => {
                    return {
                        name: item.QHMC,
                        value: item.BJSL,
                        itemStyle: {
                            color: {
                                type: "linear",
                                x: 0,
                                y: 0,
                                x2: 1,
                                y2: 1,
                                colorStops: [
                                    {
                                        offset: 1,
                                        color: "rgba(0, 146, 255, 1)",
                                    },
                                    {
                                        offset: 0,
                                        color: "rgba(0, 58, 255, 0)",
                                    },
                                ],
                            },
                        },
                    };
                }),
            },
            {
                name: "外圆",
                type: "scatter",
                emphasis: {
                    scale: false,
                },
                symbol: "circle",
                symbolSize: [5, 5],
                itemStyle: {
                    color: "#FFF",
                    shadowColor: "#0092FF",
                    shadowBlur: 5,
                    borderWidth: 1,
                    opacity: 1,
                    borderColor: "#0092FF",
                },
                z: 2,
                data: data,
                animationDelay: 500,
            },
        ],
    };
    townCountChart.setOption(option);
}

var markers_0 = [];
var markers_1 = [];
var markers_2 = [];
var markers_3 = [];
var markers = [markers_0, markers_1, markers_2, markers_3];
// 取消坐标点
function removeMarkers(markers) {
    map.remove(markers);
}
// 添加坐标点
function addMarkers(index) {
    markers[index] = [];
    for (var i = 0, marker; i < mapdata.features[index].value.length; i++) {
        marker = new AMap.Marker({
            map: map,
            position: mapdata.features[index].value[i].geometry.coordinates,
            icon: `./images/index/map_icon_${mapdata.features[index].name}.png`,
            offset: new AMap.Pixel(-13, -30),
        });
        markers[index].push(marker);
    }
}
$(".map_tl input").click(function () {
    var index = $(this).attr("name");
    if ($(this).prop("checked") == false) {
        removeMarkers(markers[index]);
    } else {
        addMarkers(index);
    }
});
var mapdata = {
    type: "FeatureCollection",
    features: [
        {
            name: "ch1",
            value: [],
        },
        {
            name: "ch2",
            value: [],
        },
        {
            name: "ch3",
            value: [],
        },
        {
            name: "ch4",
            value: [],
        },
    ],
};
// 终端事件列表
function getTerminalList() {
    $.ajax({
        url: url + "/api/v1/terminal/terminalBehaviorList",
        type: "get",
        headers: headers,
        success: function (data) {
            if (data.success) {
                data.data.forEach(function (item, index) {
                    if (item.terminalStatus === "1") {
                        mapdata.features[0].value.push({
                            type: "Feature",
                            geometry: {
                                type: "Point",
                                coordinates: [
                                    Number(item.terminalCoordinate.split(",")[0]),
                                    Number(item.terminalCoordinate.split(",")[1]),
                                ],
                            },
                            properties: { name: item.regionName },
                        });
                    } else if (item.terminalStatus === "0") {
                        mapdata.features[2].value.push({
                            type: "Feature",
                            geometry: {
                                type: "Point",
                                coordinates: [
                                    Number(item.terminalCoordinate.split(",")[0]),
                                    Number(item.terminalCoordinate.split(",")[1]),
                                ],
                            },
                            properties: { name: item.regionName },
                        });
                    } else {
                        mapdata.features[1].value.push({
                            type: "Feature",
                            geometry: {
                                type: "Point",
                                coordinates: [
                                    Number(item.terminalCoordinate.split(",")[0]),
                                    Number(item.terminalCoordinate.split(",")[1]),
                                ],
                            },
                            properties: { name: item.regionName },
                        });
                    }
                });
                for (var i = 0; i < markers.length; i++) {
                    addMarkers(i);
                }
            }
        },
    });
}
